import { http } from "@/utils/http/axios";

const BASE_URL = "/system/tenant";

// 分页查询租户列表
export function getPageList(params = {}) {
	return http.request<API.Response.BasicResponse>(
		{
			url: `${BASE_URL}/page`,
			method: "get",
			params
		},
		{
			isTransformResponse: false
		}
	);
}
// 创建租户
export function save(params = {}) {
	return http.request<API.Response.BasicResponse>(
		{
			url: `${BASE_URL}`,
			method: "post",
			data: params
		},
		{
			isTransformResponse: false
		}
	);
}
// 修改租户
export function update(params = {}) {
	return http.request<API.Response.BasicResponse>(
		{
			url: `${BASE_URL}`,
			method: "put",
			data: params
		},
		{
			isTransformResponse: false
		}
	);
}
// 获取租户信息
export function getTenant(id: number) {
	return http.request<API.Response.BasicResponse>(
		{
			url: `${BASE_URL}/${id}`,
			method: "get"
		},
		{
			isTransformResponse: true
		}
	);
}
// 删除租户
export function remove(ids: number | Array<number>) {
	return http.request<API.Response.BasicResponse>(
		{
			url: `${BASE_URL}/${ids}`,
			method: "delete"
		},
		{
			isTransformResponse: false
		}
	);
}
export function getCurrentTenant() {
	return http.request<any>(
		{
			url: `${BASE_URL}`,
			method: "GET"
		},
		{
			isTransformResponse: true
		}
	);
}
export function updateLogo(data: any) {
	return http.uploadFile<any>({
		url: `${BASE_URL}/logo`,
		method: "POST",
		data: data
	});
}

export function getTenantAll() {
	return http.request<any>(
		{
			url: `tenant/switch/list`,
			method: "GET"
		},
		{
			isTransformResponse: true
		}
	);
}
export function dynamicTenant(tenantId: string) {
	return http.request<any>({
		url: `system/tenant/dynamic/${tenantId}`,
		method: "GET"
	});
}
